package com.cd826dong.clouddemo.mq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;

@EnableBinding(SpringCloudMessageChannels.class)
public class UserMsgSender {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private SpringCloudMessageChannels springCloudMessageChannels;

    public void sendMsg(UserMsg userMsg){
        logger.debug("发送用户消息{}", userMsg);
        springCloudMessageChannels.userMsgSender().send(MessageBuilder.withPayload(userMsg).build());
    }

}
